package main

import (
	"context"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rpcinterface/client/pay"
	"github.com/robfig/cron"
	"time"
)

func agentDataInsureToChannel(){
	new(utils.KcLog).GetInstance( kcgin.AppConfig.String("crontab.log.agentDataInsureToChannel"))
	rpcPay := new(pay.Pay).Init()
	args := int( time.Now().Local().Unix() )
	reply := false
	if err := rpcPay.AngelChannelInsure(context.Background(),&args,&reply);err != nil{
		utils.Logerr.Printf("保险保费资金进入待代付任务表, 错误信息:%v.", err.Error())
	}
	utils.Logerr.Printf("保险保费资金进入待代付任务表完成.")
}

/**
 * 资金清分【保险-正常】
 * 每天01:00进行资金清分
 */
func main() {
	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	c := cron.New()
	//每天01:00执行
	spec := "0 0 1 * * ?" //秒-分-时-日-月-周【忽略】
	_ = c.AddFunc(spec,agentDataInsureToChannel)
	c.Start()
	select {}
}
